const axios = require('axios')
const qs = require('qs')



const token = '9292097509008374'
const goodsId = '128'

const instance = axios.create({
  credentials: true,
  baseURL: 'https://www.jim-i.art',
  headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36' }
})
instance.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded;'
instance.defaults.headers['token'] = token





pushList()


// 商品列表填充
function pushList() {
  setInterval(() => {
    instance.post('/api/order/apply', qs.stringify({ id: goodsId, goods_num: 1 })).then(res => {
      if (res.data.code == 1) {
        console.log(res.data.msg)
        let order_id = res.data.data.order_id
        console.log(order_id)
        axios.post('https://open.feishu.cn/open-apis/bot/v2/hook/9234b14f-e535-41e2-98dd-309f1fd2b580', { "msg_type": "text", "content": { "text": "几米锁单成功,请上号支付!!!" + order_id } })
        instance.post('/api/order/pay', qs.stringify({ order_id, pay_type: 12 })).then(res => {
          console.log(res.data)
          let url = res.data.data.payUrl
          axios.post('https://open.feishu.cn/open-apis/bot/v2/hook/9234b14f-e535-41e2-98dd-309f1fd2b580', { "msg_type": "text", "content": { "text": "几米提取链接成功,请支付!!!" + url } })
        }).catch(err => {
          console.log(err)
        })
      } else {
        console.log(res.data)
      }
    }).catch(err => {
      console.log(err)
    })
  }, 100)
}